package model

import (
	"newRetailByGolang/variable"
	"time"
)

type ParticipationRecord struct {
	Id int64
	UserId int64
	UserName string
	RegistrationActivitieId int64
	RegistrationActivitieName string
	CompletedTasksNumber float32
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (participationRecord *ParticipationRecord) QueryParticipationByActivitieId(activitieId int64) []*ParticipationRecord{
	var participationRecordList []*ParticipationRecord
	variable.Db.Where("registration_activitie_id = ?", activitieId).Find(&participationRecordList)
	return participationRecordList
}

func (participationRecord *ParticipationRecord) UpdateTasksNumber(activitieId int64, userId int64, tasksNumber float32){
	var pr ParticipationRecord
	variable.Db.Model(&pr).
		Where("registration_activitie_id = ? and user_id = ?", activitieId, userId).
		Update("completed_tasks_number", tasksNumber)
}